#! /usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import os
import sys
from batchrename import BatchRename
from myunrar import MyUnrar

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "My File Utility", size=(300, 300),
                    style=(wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX))
        panel = wx.Panel(self, -1)
        panel.Bind(wx.EVT_MOTION, self.OnMove)
        image = wx.Image('logo.png', wx.BITMAP_TYPE_PNG)
        temp = image.ConvertToBitmap()
        wx.StaticBitmap(panel, bitmap=temp, pos=(0, 0))
        wx.StaticText(panel, -1, "Welcome to Use My App.", pos=(150, 20))
        self.posCtrl = wx.TextCtrl(panel, -1, " ", pos=(100, 170))
        wx.StaticText(panel, -1, "Current Directory: ", pos=(50, 200))
        self.dirCtrl = wx.TextCtrl(panel, -1, " ", pos=(50, 220), size=(200, 20))
        self.dirCtrl .WriteText(os.getcwd())
        #
        button = wx.Button(panel, -1, "Run Batchrename", pos=(100, 130))
        button.Bind(wx.EVT_LEFT_DOWN, self.OnClick)
        #
        button2= wx.Button(panel, -1, "Run MyUnrar", pos=(100, 100))
        button2.Bind(wx.EVT_LEFT_DOWN, self.OnRarClick)

    def OnMove(self, event):
        pos = event.GetPosition()
        self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))

    def OnClick(self, event):
        rn = BatchRename()
        rn.run()

    def OnRarClick(self, event):
        ur = MyUnrar()
        ur.run()


class MyApp(wx.App):
    """Application class."""

    def OnInit(self):
        self.frame = MyFrame()
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

def main():
    app = MyApp()
    app.MainLoop()

if __name__ == '__main__':
    main()
